package com.bwie.controller;

import com.bwie.pojo.TbType;
import com.bwie.service.TbTypeService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import com.bwie.vo.TypeInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2025/7/21 15:55
 */

@RestController
@RequestMapping(value = "/prod/type")
@Slf4j
public class TbTypeController {

    @Autowired
    TbTypeService tbTypeService;

    /**
     * @description 获取商品分类树
     * @params [pageInfoVo]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/7/21 15:56
     */
    @PostMapping(value = "/getTypeList")
    public R getTypeList(@RequestBody TypeInfoVo typeInfoVo)
    {
        return tbTypeService.getTypeList(typeInfoVo);
    }

    /**
     * @description 图片上传
     * @params [file]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/7/21 16:24
     */
    @PostMapping(value = "/uploadFile")
    public R uploadFile(@RequestPart("file") MultipartFile file) {
        return tbTypeService.uploadFile(file);
    }

    /**
     * @description 添加商品分类
     * @params [tbType]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/7/22 14:30
     */
    @PostMapping(value = "/addType")
    public R addType(@RequestBody TbType tbType) {
        return tbTypeService.addType(tbType);
    }

}
